package com.hikari;

import java.awt.*;

//我方鱼类
public class MyFish {
    //定义我方鱼类图片
    Image img = GameUtils.myFish_r;
    //定义物体坐标
    int x = 700, y = 500, width = 60, height = 50;
    //定义移动速度
    int speed = 25;
    //等级
    int level = 1;
    //移动方向 从左至右为1   从右至左为-1
    int dir = 1;
    //分值
    int count;

    //绘制自身的方法检测
    public void paintSelf(Graphics g) {
        logic();
        g.drawImage(img, x, y, width+GameUtils.count, height+GameUtils.count, null);

    }

    //获取矩形用于碰撞
    public Rectangle getRect() {
        return new Rectangle(x, y, width+GameUtils.count, height+GameUtils.count);
        //11-2
    }

    void logic() {
        if (GameUtils.UP) {
            y = y - speed;
        }
        if (GameUtils.DOWN) {
            y = y + speed;
        }
        if (GameUtils.LEFT) {
            x = x - speed;
            img = GameUtils.myFish_l;
        }
        if (GameUtils.RIGHT) {
            x = x + speed;
            img = GameUtils.myFish_r;
        }
    }
}
